using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.TestDrivens;
using Pixysoft.Framework.Logs.Core;
using System.IO;

namespace Pixysoft.Framework.Logs.TestCases
{
    [TestDriven(TestDrivenType.IntegrationTest, "Recorder")]
    class UnitTest_019_Recorder
    {
        private static IAssert assert = Assert.New(true);

        [TestStart]
        public static bool TestCaseStart()
        {
            return true;
        }

        [TestStop]
        public static void TestCaseStop()
        {
        }

        [TestStateSave]
        public static ITestDrivenDocument TestCaseStateSave()
        {
            return assert.Document;
        }

        [TestCase("Append")]
        public static void TestCase_000_Append()
        {
            Assert.Call(UnitTest_012_Document.TestCase_000_InitializeDocument);

            IDocument doc = Assert.Cache.Pop<IDocument>();
            assert.Write(doc.Serialize(true));


            string path = StringFilter.RegularPath(AppDomain.CurrentDomain.BaseDirectory);
            string filename = "pixysoft";
            string postfix = ".log";

            Recorder recorder = new Recorder(path, filename, postfix);
            recorder.Append(doc);
            assert.Write(File.ReadAllText(path + filename + postfix));
            recorder.Append(doc, true);
            assert.IsFalse(File.Exists(path + filename + postfix));
            recorder.Insert(doc);
            assert.Write(File.ReadAllText(path + filename + postfix));
            recorder.Append(doc.Records[0]);
            assert.Write(File.ReadAllText(path + filename + postfix));
        }
    }
}
